import json
import sys
import sys as s

def value_of(_, a):
	return a.value

def key_of(_, a):
	return a.key

def add(a,b):
	return a + b


class ItemClass:
	def __init__(self):
		self.key = None
		self.value = None

item = ItemClass()
result = {}

for line1357 in open(sys.argv[1]):
	line1357 = line1357.strip()
	item.key = json.loads(line1357.split("\t")[0])
	item.value = json.loads(line1357.split("\t")[1])
	
	item_key=key_of(None,item)
	result[item_key]=(add(value_of(None,item),1)) if (item_key in result ) else (add(value_of(None,item),1))

outfile = open(sys.argv[2], "w")

for key, value in result.items():
	outfile.write("%s\t%s\n" % (json.dumps(key), json.dumps(value)))

outfile.close()

